<div style="padding-left: 10px;">
    <div style="float: left;margin-top: 50px;width: 180px;  border-right: 1px #ebebeb solid;">
        <div class="hd">
            <h3>好友分组</h3>
        </div>
        <div class="bd">
            <ul class="" id="group_list" style="width: 160px;">
                <li rel="-10000" class="" id="group__10000">

                    <a class="a" onclick="showList(-1),edit()">全部好友</a>
                    <span class="num" style="">({$user_all_count})</span>
                </li>
                <li rel="0" id="group_0" class="">

                    <a class="js_left_gname a" onclick="showList(0),edit()">未分组</a>
                    <span class="num" style="display: inline;">({$user_wei_count})</span>
                </li>
                <volist name="friend" id="vo">

                    <li rel="-2" id="group__2" class="grouplist1" style="margin-top: 10px;">
                        <div style="width: 150px;">

                            <div style="float: left">
                                <a class="js_left_gname a" onclick="showList('{$vo.groupid}'),edit('{$vo.groupid}')">{$vo.groupname}</a>
                                <span class="num" style="display: inline;">({$vo.count})</span>
                            </div>
                            <div style="float: right">
                                <a id="edit{$vo.groupid}" onclick="showedit('{$vo.groupid}')" class="act-edit a "
                                   style="display: none; ">编辑</a>
                            </div>
                            <div class="group-action group-edit" style="float:left;display: none;margin-top: 5px;" id="edit_group_div{$vo.groupid}">
                                    <input type="text" class="text" onkeyup="CheckInputCount(this,6)"
                                           id="edit_gname{$vo.groupid}" maxlength="6" value="{$vo.groupname}">
                                <p class="act" style="margin-top: 5px;">
                                    <input onclick="edit_gname('{$vo.groupid}')" class="btn_add" type="submit" value="保存"/>
                                    <input onclick="hideeditdiv('{$vo.groupid}')" class="btn_add" type="submit" value="取消"/>

                                </p>
                            </div>

                            <div class="clearfix"></div>
                        </div>

                    </li>
                </volist>
            </ul>
        </div>
        <div style="margin-top: 20px;">
            <div onclick="showdiv()" class="creat_group_btn" > 创建分组</div>

            <div class="group-action group-create" style="display: none;margin-top: 5px;" id="create_group_div">
                    <input type="text" class="text" onkeyup="CheckInputCount(this,6)" id="create_gname" maxlength="6">
                <p class="act" style="margin-top: 5px;">
                    <input onclick="create_gname()" class="btn_add" type="submit" value="保存"/>
                    <input onclick="hidediv()" class="btn_add" type="submit" value="取消"/>

                </p>

            </div>


        </div>
    </div>
</div>

<script>
    function edit(gid) {
        $(".grouplist1 .act-edit").hide();
        $(".group-edit").hide();
        document.getElementById('edit' + gid).style.display = " block";
    }
    function showdiv() {
        document.getElementById("create_group_div").style.display = " block";
    }
    function hidediv() {
        document.getElementById("create_group_div").style.display = " none";
    }
    function hideeditdiv(id) {
        document.getElementById("edit_group_div" + id).style.display = " none";
    }

    function showedit(id) {
        document.getElementById("edit_group_div" + id).style.display = " block";
    }
    function edit_gname(groupid) {
        $.post(U("friend/Index/editgroup"), { groupname: $('#edit_gname' + groupid).val(), groupid: groupid}, function (data) {
            if(data.status == 1){
                ui.success('修改分组成功！')
            }
            $('#grouplist').load(U("friend/Index/_grouplist"));
            $('#friendlist').load(U("friend/Index/_friendlist" + '&groupid=' + groupid));
        }, 'json');
    }
    function create_gname() {
        $.post(U("friend/Index/addgroup"), { groupname: $('#create_gname').val()}, function (data) {
            if(data.status == 1){
                ui.success('添加分组成功！')
            }
            $('#grouplist').load(U("friend/Index/_grouplist"));
        }, 'json');
    }
</script>